package com.jrzh.mvc.controller.sys.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.jrzh.framework.annotation.NoAdminLogin;
import com.jrzh.framework.annotation.NoPermission;
import com.jrzh.framework.annotation.RequiredPermission;
import com.jrzh.framework.annotation.UserEvent;
import com.jrzh.framework.base.controller.BaseAdminController;
import com.jrzh.framework.bean.JqDataGrid;
import com.jrzh.framework.bean.ResultBean;
import com.jrzh.mvc.constants.SysActionConstants;
import com.jrzh.mvc.search.sys.I18nSearch;
import com.jrzh.mvc.service.sys.I18nServiceI;
import com.jrzh.mvc.view.sys.I18nView;

@RestController(I18nController.LOCATION +"/I18nController")
@RequestMapping(I18nController.LOCATION)
public class I18nController extends BaseAdminController{
	public static final String LOCATION = "sys/admin/i18n";
	
	@Autowired
	I18nServiceI i18nService;
	
	@PostMapping(value = "datagrid")
	@UserEvent(desc = "I18n列表查询")
	@RequiredPermission(key =  SysActionConstants.INDEX)
	public JqDataGrid<I18nView> datagrid(I18nSearch search) {
		JqDataGrid<I18nView> dg = new JqDataGrid<I18nView>();
		try {
			dg = i18nService.datagrid(search);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return dg;
	}
	
	@PostMapping(value = "getData")
	@NoAdminLogin
	@NoPermission
	public ResultBean getData(String lan) {
		ResultBean result = new ResultBean();
	    try{
	    	result.setObjs(i18nService.getData(lan));
	    	result.setStatus(ResultBean.SUCCESS);
	    } catch (Exception e){
	    	log.error(e.getMessage());
	    	result.setMsg(e.getMessage());
	    }
		return result;
	}
	
	@Override
	protected void setData() {
		
	}
}
